var web = web || {};
web.ActionSelect = Class.create(); 
web.ActionSelect.prototype = {
	initialize: function(options) {
		var _this = this;
		this.settings = $.extend({
			evt: 'click',
			bodyHandler: function(){},
			css: {box: 'select-box', menu: 'select-menu', show:'action-select-show'}
		}, options);
		
		this.select = null;
		this.selBox = null;
		this.selMenu = null;
	},
	bind: function(elem) {
		var _this = this;
		if (1 != elem.size()) return;
		
		this.select = elem;
		this.selBox = this.select.children(this.settings.css.box);
		this.selMenu = this.select.children(this.settings.css.menu);
		
		if (this.settings.evt == 'over') {
			this.select.bind({
				mouseenter: function(){_this._showMenu();},
				mouseleave: function(){_this._hideMenu();},
				click: function(){return false;}
			});
		} else {
			this.select.bind('click', function(){_this._showMenu();return false;});
		}
		
		$('html').bind('click', function(){
			_this._hideMenu();
		});		
	},
	_showMenu: function() {
		this.select.addClass(this.settings.css.show);
	},
	_hideMenu: function() {
		this.select.removeClass(this.settings.css.show);
	}	
};

(function($){  
	$.fn.actionSelect = function(options){ 
		return this.each(function(){
			new web.ActionSelect(options).bind($(this));
		});
	}
})(jQuery); 

